package com.aounhui.productor.common;

import com.aounhui.common.utils.UUIDUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;

/**
 * @author aounhui
 * @version 1.0
 * @date 2021/6/29 16:35
 * @description
 */
@Component
public class SendMessage {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    public void sendMessage(String type, String content) {
        HashMap<String, String> messageMap = new HashMap<>();
        messageMap.put("messageId", UUIDUtil.getUUID());
        messageMap.put("type", type);
        messageMap.put("content", content);
        messageMap.put("createTime", String.valueOf(new Date()));
        rabbitTemplate.convertAndSend("productDirectExchange", "productDirectRouting", messageMap);
    }
}
